﻿using System;
using DataBaseLibrary.DBObjectsFB;

namespace DocMreoLiteVersion.Reports.SaleContractReport
{
    //TODO: Возможно, так организовывать класс для привязки отчёта к данным - тупость. Когда придумаю умнее - переделать!

    public class DataReportBindingSalesContract
    {
        public String DateSalesContract { get; set; } //Дата создания договора!
        public String NumberSalesontract { get; set; }//Номер созданного договора!

        //Информация о покупателе
        public String LastNameBuyer { get; set; }
        public String FirstNameBuyer { get; set; }
        public String PatronymicBuyer { get; set; }
        public String DateOfBirthBuyer { get; set; }
        //Распортные данные
        public String SerialBuyer { get; set; }
        public String NumberBuyer { get; set; }
        public String DateIssuePassportBuyer { set; get; }
        public String PassportIssuedByBuyer { get; set; }
        //Адрес покупателя
        public String CityBuyer { get; set; }
        public String StreetBuyer { get; set; }
        public String NumberBuildingBuyer { get; set; } //Номер корпуса
        public String NumberFlatBuyer { get; set; } //Номер квартиры
        public String NumberHomeBuyer { get; set; } //Номер дома
        public String ResidentialAreaBuyer { get; set; } //Область, край


        //Информация о продавце
        public String LastNameSaler { get; set; }
        public String FirstNameSaler { get; set; }
        public String PatronymicSaler { get; set; }
        public String DateOfBirthSaler { get; set; }
        //Распортные данные
        public String SerialSaler { get; set; }
        public String NumberSaler { get; set; }
        public String DateIssuePassportSaler { set; get; }
        public String PassportIssuedBySaler { get; set; }
        //Адрес покупателя
        public String CitySaler { get; set; }
        public String StreetSaler { get; set; }
        public String NumberBuildingSaler { get; set; }
        public String NumberFlatSaler { get; set; }
        public String NumberHomeSaler { get; set; }
        public String ResidentialAreaSaler { get; set; }

        //Информация о ТС
        public String CostMachine { get; set; }
        public String CostMachineString { get; set; }

        public String RegZnak { get; set; }
        public String VIN { get; set; }
        public String DopVIN { get; set; }
        public String Model { get; set; }
        public String Shassi { get; set; }
        public String Kuzov { get; set; }
        public String ColorM { get; set; }
        public String TypeTC { get; set; }
        public String YeahrManufacturing { get; set; }
        public String CategoryTC { get; set; }

        public String PTC_series { get; set; }
        public String PTC_number { get; set; }
        public String PTC_issued_by { get; set; }
        public String PTC_date_issued { get; set; }


        public String NumberRegContr { get; set; }
        public String SeriesRegContr { get; set; }
        public String DateIssueRegContr { get; set; }
        public String IssuedByRegContr { get; set; }

        public DataReportBindingSalesContract(SalesContract sales_contract)
        {

            DateSalesContract = sales_contract.DateCreateContract.ToString("d");

            if (CSettings.SaleContractSettings.IsPrintNumberContract)
                NumberSalesontract = (sales_contract as SalesContract).NumberSalesContract;
            else
                NumberSalesontract = "";
            //Заполнение данных о покупателе
            LastNameBuyer = sales_contract.Buyer.m_Individual.LastName;
            FirstNameBuyer = sales_contract.Buyer.m_Individual.FirstName;
            PatronymicBuyer = sales_contract.Buyer.m_Individual.Patronymic;
            DateOfBirthBuyer = sales_contract.Buyer.m_Individual.DateOfBirth == null ? "" : ((DateTime)sales_contract.Buyer.m_Individual.DateOfBirth).ToString("d");
            SerialBuyer = sales_contract.Buyer.m_Individual.PassportSeries;
            NumberBuyer = sales_contract.Buyer.m_Individual.PassportNumber;
            DateIssuePassportBuyer = sales_contract.Buyer.m_Individual.PassportDateIssue == null ? "" : ((DateTime)sales_contract.Buyer.m_Individual.PassportDateIssue).ToString("d");
            PassportIssuedByBuyer = sales_contract.Buyer.m_Individual.PassportIssuedBy;

            CityBuyer = sales_contract.Buyer.m_Individual.Address.City;
            StreetBuyer = sales_contract.Buyer.m_Individual.Address.Street;
            NumberBuildingBuyer = sales_contract.Buyer.m_Individual.Address.NumberBuilding;
            NumberFlatBuyer = sales_contract.Buyer.m_Individual.Address.NumberFlat;
            NumberHomeBuyer = sales_contract.Buyer.m_Individual.Address.NumberHome;
            ResidentialAreaBuyer = sales_contract.Buyer.m_Individual.Address.ResidentialArea;

            //Заполнение данных о продавце
            LastNameSaler = sales_contract.Saler.m_Individual.LastName;
            FirstNameSaler = sales_contract.Saler.m_Individual.FirstName;
            PatronymicSaler = sales_contract.Saler.m_Individual.Patronymic;
            DateOfBirthSaler = sales_contract.Saler.m_Individual.DateOfBirth == null ? "" : ((DateTime)sales_contract.Saler.m_Individual.DateOfBirth).ToString("d");
            SerialSaler = sales_contract.Saler.m_Individual.PassportSeries;
            NumberSaler = sales_contract.Saler.m_Individual.PassportNumber;
            DateIssuePassportSaler = sales_contract.Saler.m_Individual.PassportDateIssue == null ? "" : ((DateTime)sales_contract.Saler.m_Individual.PassportDateIssue).ToString("d");
            PassportIssuedBySaler = sales_contract.Saler.m_Individual.PassportIssuedBy;

            CitySaler = sales_contract.Saler.m_Individual.Address.City;
            StreetSaler = sales_contract.Saler.m_Individual.Address.Street;
            NumberBuildingSaler = sales_contract.Saler.m_Individual.Address.NumberBuilding;
            NumberFlatSaler = sales_contract.Saler.m_Individual.Address.NumberFlat;
            NumberHomeSaler = sales_contract.Saler.m_Individual.Address.NumberHome;
            ResidentialAreaSaler = sales_contract.Saler.m_Individual.Address.ResidentialArea;


            //Инфа о ТС
            RegZnak = sales_contract.Vehicle.ORegistrInformation.StateRoom;
            VIN = sales_contract.Vehicle.VIN;
            DopVIN = sales_contract.Vehicle.ORegistrInformation.DopVin;
            Model = sales_contract.Vehicle.ModelVehicle;
            Shassi = sales_contract.Vehicle.OTechnicalCharacteristics.NumberChassis;
            Kuzov = sales_contract.Vehicle.OTechnicalCharacteristics.NumberCarcass;
            ColorM = sales_contract.Vehicle.OTechnicalCharacteristics.Color;
            TypeTC = sales_contract.Vehicle.TypeVehicle;
            YeahrManufacturing = sales_contract.Vehicle.YearManufacture == null ? "" : ((DateTime)sales_contract.Vehicle.YearManufacture).Year.ToString();
            CategoryTC = sales_contract.Vehicle.Category;

            PTC_series = sales_contract.Vehicle.ORegistrInformation.SeriesPts;
            PTC_number = sales_contract.Vehicle.ORegistrInformation.NumberPts;
            PTC_issued_by = sales_contract.Vehicle.ORegistrInformation.IssueByPts;
            PTC_date_issued = sales_contract.Vehicle.ORegistrInformation.DateIssuePts == null ? "" : ((DateTime)sales_contract.Vehicle.ORegistrInformation.DateIssuePts).ToString("d");


            NumberRegContr = sales_contract.Vehicle.ORegistrInformation.NumberRegistrSert;
            SeriesRegContr = sales_contract.Vehicle.ORegistrInformation.SeriesRegistrSert;
            DateIssueRegContr = sales_contract.Vehicle.ORegistrInformation.DateRegistrSert == null ? "" : ((DateTime)sales_contract.Vehicle.ORegistrInformation.DateRegistrSert).ToString("d");
            IssuedByRegContr = sales_contract.Vehicle.ORegistrInformation.IssuedByRegistrSert;


            CostMachine = String.Format("{0, 0:C}", (sales_contract as SalesContract).Price);
            CostMachineString = RuDateAndMoneyConverter.CurrencyToTxt((sales_contract as SalesContract).Price, true);

        }
    }
}
